<?php
class PloyPinsController extends AppController
{
	public $name = 'PloyPins';
	public $uses=array('PloyPin');
    private $codesArr;
    public $testArr=array(
        'from'=>'wechat',
        'code'=>'A02b2650n6DV5',
        'pid'=>'13923458888',
        'token'=>'b15e9f7522ef99cd1135',
        'provinceId'=>0
        );
    /**
     * [api description]
     * 对外开放的api调用接口
     * 接收示例：
     * {"from":"wechat","code":"102A21F00JPPE","pid":"13923458888",
     * "token":"6ab0938dafd06f2e59de","provinceId":"0"}
     * @return [json] [description]
     * 
     */
    public function api()
    {
        $_POST=$this->testArr;//测试使用
        $_POST['code']=strtoupper($_POST['code']);
        $flag=$this->PloyPin->checkFrom($_POST);
        if ($flag!=1) {
            $return['errorMsg']='非法信息来源';
            $return['errorNum']=1;
            echo json_encode($return);
            exit;
        }
        $this->codesArr=$this->PloyPin->cutData($_POST['code']);
        $codeFlag=$this->PloyPin->checkCode($this->codesArr);//检查号码的合法性
        $usedFlag=$this->PloyPin->checkUse($this->codesArr['num']);
        var_dump($usedFlag);
        exit;
        
    }

     
}
?>